package symbol;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

public class FuncVariableTable {

	// 存储func变量使用过的类型（解决重载函数赋值给func变量）
	private HashMap<String, HashSet<FuncParamsTypeList>> ident2params = new HashMap<String, HashSet<FuncParamsTypeList>>();
	
	public FuncVariableTable() {}
	
	public void addFuncvarInfo(String funcVarkey, ArrayList<String> params, String returnType) {
		if (!ident2params.containsKey(funcVarkey)) {
			ident2params.put(funcVarkey, new HashSet<FuncParamsTypeList>());
		}
		ident2params.get(funcVarkey).add(new FuncParamsTypeList(params, returnType));
	}
	
	public String toString() {
		String returnString = "";
		for (String key : ident2params.keySet()) {
			returnString += key + " : [";
			for (FuncParamsTypeList l : ident2params.get(key)) {
				returnString += l.toString() + ", ";
			}
			returnString += "\n";
		}
		return returnString;
	}
}
